//
//  LineItem.m
//  mock-store
//
//  Created by aewatson on 10/20/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "LineItem.h"


@implementation LineItem

@synthesize quantity;
@synthesize item;

-(id)initWithItem: (Item*) newItem andQuantity: (int) newQuantity {
    self = [super init];
    if(self) {
        item = newItem;
        quantity = newQuantity;
    }
    return self;
}

-(float)getLineItemTotalFloat {
    return quantity * [self getItemPriceFloat];
}

-(NSString*)getLineItemTotalString {
    return [NSString stringWithFormat:@"$%0.2f", [self getLineItemTotalFloat]]; 
}

-(NSString*)getItemName {
    return item.itemName;
}

-(NSString*)getItemDescription {
    return item.itemDescription;
}

-(NSString*)getItemSKU {
    return item.itemSKU;
}

-(NSString*)getItemPriceString {
    return [NSString stringWithFormat:@"$%0.2f", [item.itemPrice floatValue]];
}

-(float)getItemPriceFloat {
    return [item.itemPrice floatValue];
}

-(NSString*)getLineItemSummaryString {
    return [NSString stringWithFormat:@"%@  Qty: %i  Tot: %@", [self getItemName], quantity, [self getItemPriceString]];
}

@end
